package com.aaa.controller;

import com.aaa.entity.Product;
import com.aaa.entity.User;
import com.aaa.service.impl.ProductServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@Controller
@RequestMapping("product")
public class ProductController {
    @Resource
    ProductServiceImpl productService;
    @RequestMapping("list")
    @ResponseBody
    public List<Product> list(){
        return productService.list();
    }
    @RequestMapping("save")
    @ResponseBody
    public boolean save(Product product){
        return productService.save(product);
    }
    @RequestMapping("update")
    @ResponseBody
    public boolean update(Product product){
        return productService.updateById(product);
    }
    @RequestMapping("remove")
    @ResponseBody
    public boolean remove(Integer pid){
        return productService.removeById(pid);
    }
    @RequestMapping("select")
    @ResponseBody
    public List<Product> select(){
        return productService.select();
    }
    @RequestMapping("select2")
    @ResponseBody
    public List<Product> select2(){
        return productService.select2();
    }
    @RequestMapping("select3")
    @ResponseBody
    public List<Product> select3(String pname){
        return productService.select3(pname);
    }
}
